package com.kcwl.carrier.infrastructure.repository.persostence;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.kcwl.carrier.domain.entity.AuditRejectReasonInfo;
import com.kcwl.carrier.domain.repository.IAuditRejectReasonRepository;
import com.kcwl.carrier.infrastructure.repository.mapper.AuditRejectReasonMapper;
import com.kcwl.carrier.infrastructure.repository.po.AuditRejectReasonPO;
import com.kcwl.carrier.interfaces.query.AuditRejectReasonQuery;
import com.kcwl.ddd.domain.repository.BaseRepositoryImpl;
import com.kcwl.framework.utils.KcBeanConverter;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @author 刘旭超
 * @date 2022年07月11日 16:33
 * @Description
 */
@Service
public class AuditRejectReasonRepositoryImpl extends BaseRepositoryImpl<AuditRejectReasonMapper, AuditRejectReasonPO> implements IAuditRejectReasonRepository {

    @Resource
    private AuditRejectReasonMapper auditRejectReasonMapper;


    @Override
    public Class<AuditRejectReasonPO> getPoClass() {
        return AuditRejectReasonPO.class;
    }


    @Override
    public List<AuditRejectReasonInfo> selectIds(List<Long> ids) {
        QueryWrapper<AuditRejectReasonPO> wrapper = new QueryWrapper<>();
        wrapper.in("id", ids);
        return KcBeanConverter.toList(auditRejectReasonMapper.selectList(wrapper), AuditRejectReasonInfo.class);
    }

    @Override
    public List<AuditRejectReasonInfo> queryRejectReason(AuditRejectReasonQuery query) {
        QueryWrapper<AuditRejectReasonPO> wrapper = new QueryWrapper<>();
        wrapper.eq("biz_type", query.getBizType());
        return KcBeanConverter.toList(auditRejectReasonMapper.selectList(wrapper), AuditRejectReasonInfo.class);
    }

    @Override
    public List<AuditRejectReasonInfo> queryAllRejectReason() {
        QueryWrapper<AuditRejectReasonPO> wrapper = new QueryWrapper<>();
        return KcBeanConverter.toList(auditRejectReasonMapper.selectList(wrapper), AuditRejectReasonInfo.class);
    }

    @Override
    public AuditRejectReasonInfo selectId(Long id) {
        QueryWrapper<AuditRejectReasonPO> wrapper = new QueryWrapper<>();
        wrapper.eq("id", id);
        return KcBeanConverter.toBean(auditRejectReasonMapper.selectOne(wrapper), AuditRejectReasonInfo.class);
    }
}
